const express = require('express');
const router = express.Router();
const announcementController = require('../controllers/announcementController');
const authMiddleware = require('../middleware/authMiddleware');

// 公开路由
// 获取公告列表（公开）
router.get('/', announcementController.getAnnouncements);

// 获取公告详情（公开）
router.get('/:id', announcementController.getAnnouncementDetail);

// 管理员路由
// 获取管理员公告列表（支持筛选和分页）
router.get('/admin/list', authMiddleware, announcementController.getAdminAnnouncements);

// 创建公告
router.post('/admin', authMiddleware, announcementController.createAnnouncement);

// 更新公告
router.put('/admin/:id', authMiddleware, announcementController.updateAnnouncement);

// 发布公告
router.post('/admin/:id/publish', authMiddleware, announcementController.publishAnnouncement);

// 撤回公告
router.post('/admin/:id/recall', authMiddleware, announcementController.recallAnnouncement);

// 删除公告
router.delete('/admin/:id', authMiddleware, announcementController.deleteAnnouncement);

module.exports = router;